package com.mshop.web;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.mshop.util.WebContext;
import com.mshop.util.WebUtil;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Oct 20, 2008 6:17:40 PM
 * @version $Id: WapAction.java,v 1.2 2010/04/11 05:27:16 airsou Exp $
 */
public abstract class WebAction extends BaseAction {
	/**
	 * Comment for <code>serialVersionUID</code>
	 * 
	 */
	protected Log log = LogFactory.getLog(this.getClass());
	private static final long serialVersionUID = 1L;
	protected String act;
	protected int page;
	protected int pagePerSize;
	protected int startRow;
	protected String id;
	protected String key;

	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(String key) {
		this.key = key;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the act
	 */
	public String getAct() {
		return act;
	}

	public abstract long getObjectId();

	public int getPage() {
		return page;
	}

	public int getPagePerSize() {
		return pagePerSize;
	}

	public int getStartRow() {
		return startRow;
	}

	@Override
	public String process(WebContext context) {
		if (pagePerSize <= 0) {
			pagePerSize = 20;
		}
		if (page <= 0) {
			page = 1;
		}
		startRow = (page - 1) * pagePerSize;
		return webProcess(context);
	}

	/**
	 * @param act
	 *            the act to set
	 */
	public void setAct(String act) {
		this.act = act;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public void setPagePerSize(int pagePerSize) {
		this.pagePerSize = pagePerSize;
	}

	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}

	public abstract String webProcess(WebContext context);
	
	public static void main(String[] args){
		Date time=new Date();
		System.out.println(time+":"+new Date().getTime());
	}
}